From e0f1a3f6517963aadd92965681d3d07e77c281e0 Mon Sep 17 00:00:00 2001 From: robertl Date: Fri, 21 Feb 2003 14:42:06 +0000 Subject: [PATCH] (Blindly) Add shortname support to magnav. --- gpsbabel/magnav.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/gpsbabel/magnav.c b/gpsbabel/magnav.c index 64ae31041..fbae0af40 100644 --- a/gpsbabel/magnav.c +++ b/gpsbabel/magnav.c @@ -52,6 +52,8 @@ struct record { static FILE *file_in; static FILE *file_out; static const char *out_fname; +static void *mkshort_handle; + struct pdb *opdb; struct pdb_record *opdb_rec; @@ -78,12 +80,15 @@ wr_init(const char *fname, const char *args) if (file_out == NULL) { fatal(MYNAME ": Cannot open %s for writing\n", fname); } + mkshort_handle = mkshort_new_handle(); + setshort_length(mkshort_handle, 20); } static void wr_deinit(void) { fclose(file_out); + mkshort_del_handle(mkshort_handle); } static void @@ -144,7 +149,10 @@ my_writewpt(const waypoint *wpt) struct tm *tm; char *vdata; time_t tm_t; - + const char *sn = global_opts.synthesize_shortnames ? + mkshort(mkshort_handle, wpt->description) : + wpt->shortname; + rec = xcalloc(sizeof(*rec)+56,1); if ( wpt->creation_time ) { @@ -181,8 +189,8 @@ my_writewpt(const waypoint *wpt) rec->unknown3 = 'a'; vdata = (char *)rec + sizeof(*rec); - if ( wpt->shortname ) { - strncpy( vdata, wpt->shortname, 21 ); + if ( sn ) { + strncpy( vdata, sn, 21 ); vdata[20] = '\0'; } else { -- 2.30.2